//
//  Tool.m
//  News
//
//  Created by 徐涵菲 on 2018/4/23.
//  Copyright © 2018年 Wangly. All rights reserved.
//

#import "Tool.h"

@implementation Tool

+(UIBarButtonItem *)itemWithImage:(NSString *)image higImage:(NSString *)higImage target:(id)target action:(SEL)action
{
    //创建按钮
    UIButton *btn=[[UIButton alloc]init];
    //设置对应状态图片
    [btn setImage:[UIImage imageNamed:image] forState:UIControlStateNormal];
    [btn setImage:[UIImage imageNamed:higImage] forState:UIControlStateHighlighted];
    //设置frame
    btn.size=btn.currentImage.size;
    //添加监听事件
    [btn addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
    
    return [[UIBarButtonItem alloc] initWithCustomView:btn];
}

@end
